﻿using System.Collections.Generic;

public class DicAndParam
{

    public static Dictionary<string, object> ToDictionary(params object[] parameterValues)
    {
        Dictionary<string, object> d = new Dictionary<string, object>();
        if (parameterValues != null)
            for (int i = 0; i < parameterValues.Length; i++)
            {
                d.Add("@Parameter" + i.ToString(), parameterValues[i]);
            }
        else
            d = null;
        return d;
    }

    public static object[] ToParams(Dictionary<string, object> d)
    {
        object[] parameterValues = null;
        if (d != null)
        {
            parameterValues = new object[d.Count];
            d.Values.CopyTo(parameterValues, 0);

            // or in C# 3.0:
            //parameterValues = dict.Values.ToArray();
        }
        return parameterValues;
    }
}

